<div class="layui-card-header layui-card">
    <span class="layui-breadcrumb" lay-filter="breadcrumb">
        <a lay-href="">首页</a>
        <a><cite>商户</cite></a>
        <a><cite>应用列表</cite></a>
    </span>
</div>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-tab layui-tab-brief">
            <ul class="layui-tab-title">
                <li class="layui-this">应用列表信息</li>
            </ul>
            <div class="layui-tab-content">
                <div class="layui-row">
                    <div class="layuiAdmin-btns" style="margin-bottom: 10px;">
                        <a class="layui-btn" id="create"><i class="layui-icon layui-icon-add-1"></i>新建应用</a>
                    </div>
                </div>
                <table class="layui-hide" id="tList" lay-filter="tList"></table>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="xxpayBar">
    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="detail"><i class='layui-icon layui-icon-about'></i>详情</a>
    <a class="layui-btn layui-btn-xs" lay-event="edit"><i class='layui-icon layui-icon-edit'></i>编辑</a>
    <a class="layui-btn layui-btn-xs" lay-event="codeImage"><i class='layui-icon layui-icon-picture'></i>二维码管理</a>
</script>

<script>
    layui.use(['table','util', 'view'], function(){
        var table = layui.table
        ,$ = layui.$
        ,element = layui.element
        ,view = layui.view;
        
        element.render('breadcrumb', 'breadcrumb');//渲染导航信息

        table.render({
            elem: '#tList'
            ,url: layui.setter.baseUrl + '/app/list'
            ,where: {
                access_token: layui.data(layui.setter.tableName).access_token
            }
            ,id: 'tableReload'
            ,cols: [[
                {type:'checkbox'}
                ,{field:'appId', title: '应用ID', sort: true }
                ,{field:'appName', title: '应用名称' }
                ,{field:'status',  title: '应用状态',templet: '<div>{{d.status == 0?"停止使用":"使用中"}}</div>' }
                ,{field:'createTime', width: 200,  title: '创建时间', templet: '<div>{{ layui.util.toDateString(d.createTime) }}</div>' }
                ,{field:'edite', width: 250, fixed: "right", title: '操作', toolbar: '#xxpayBar'}
            ]]
            ,page: true
            ,skin: 'line'
        });

        //监听工具条
        table.on('tool(tList)', function(obj){
            var data = obj.data;
            if(obj.event === 'detail'){
                view.xxpayPopup("查看商户应用", "account/app/detail", {appId: data.appId}, {btn: false,area: ['60%', '65%']});
            } else if(obj.event === 'edit'){
                view.xxpayPopup("编辑商户应用", "account/app/update", {appId: data.appId}, {area: ['60%', '65%']});
            } else if(obj.event === 'codeImage'){
                location.hash = "/account/qrcode/list/appId=" + data.appId;
            }
        });

        $("#create").on('click', function () {
            view.xxpayPopup("新建应用", "account/app/create", null, {area: ['60%', '65%']});
        });

    });
</script>